package com.cn.hotel.service.impl;

import com.cn.hotel.dao.INewsDao;
import com.cn.hotel.dao.Impl.NewsImpl;
import com.cn.hotel.model.NewsModel;
import com.cn.hotel.model.NewsTypeModel;
import com.cn.hotel.service.INewsService;

import java.util.List;

public class NewsServiceImpl implements INewsService {
    /**
     * 查询所有的新闻
     *
     * @param newsModel
     * @return
     */
    @Override
    public List<NewsModel> findAll(NewsModel newsModel) {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.findAll(newsModel);
    }
    /**
     * 获得数据库新闻总条数
     *
     * @param newsModel
     * @return
     */
    @Override
    public int getCount(NewsModel newsModel) {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.getCount(newsModel);
    }

    /**
     * 添加新闻
     * @param newsModel
     * @return
     */
    @Override
    public int add(NewsModel newsModel) {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.add(newsModel);
    }

    /**
     * 通过id查询当前点击的id的所有信息 给页面返回
     * @param temp
     * @return
     */
    @Override
    public NewsModel findById(Integer temp) {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.findById(temp);
    }

    /**
     * 保存修改
     * @param newsModel
     * @return
     */
    @Override
    public int newsEdit(NewsModel newsModel) {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.newsEdit(newsModel);
    }

    @Override
    public int delete(Integer aa) {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.delete(aa);
    }
//前端获取数据代码-----------------------------------
    @Override
    public List<NewsTypeModel> getNewsTypeModelList() {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.getNewsTypeModelList();
    }

    /**
     * 网站首页调取5条新闻数据
     * @return
     */
    @Override
    public List<NewsModel> getHomeNewsModelList() {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.getHomeNewsModelList();
    }

    @Override
    public List<NewsModel> getNewsModelList() {
        INewsDao iNewsDao = new NewsImpl();
        return iNewsDao.getNewsModelList();
    }
}

